// Appendix Table 11: 
use "$dir\DataSCLB", clear
	// Globals
	global moderators_SaT Dmiss_BL Dmale Lage L_BLabil DTeachMale LTeachAge LTeachExper LTeachEduc 
	global SaT  ""
	foreach var of global moderators_SaT  {
		global SaT  "$SaT `var' MT_`var' CCT_`var'"
	}			   

	// Create Treatment Indicators
	gen treatb_MT = MT_Program
	gen treatb_CCT = CCT_Program
	
	areg EL_EGRA_PCA_Index treatb_MT treatb_CCT $SaT, a(Group_detailed) cluster(School_blind)
	local adj_cmd gen Y_nosys_SaT =  EL_EGRA_PCA_Index
	foreach var of global moderators_SaT  {
		local adj_cmd `adj_cmd' - MT_`var'*_b[MT_`var'] - CCT_`var'*_b[CCT_`var'] 
	}
	`adj_cmd'
	// Estimate the Bounds
		set seed 67296786
		fhbounds Y_nosys_SaT, r(1000) treatment(MT_Program CCT_Program) control(Control) strata(Group_blind) cluster(School_blind) bias
		keep if p==5 | p==25 | p==50 | p==75 | p==95  | (p>99)
		keep p_exp *_st i p sortvar
		
		save "$output/AppendixTable11.dta", replace
		
	
			keep p i *lo* 
			keep if p<100
			egen group = group(p)
			gsort - group i
			gen sortvar = _n
			rename FH_lo_MT_Program_pt_st  FH_lo_MT_Program_pt_st_rev
			rename FH_lo_CCT_Program_pt_st FH_lo_CCT_Program_pt_st_rev
			tempfile reverse
			save `reverse'
			use "$output/AppendixTable11.dta", clear
			drop sortvar
			gen sortvar = _n
			qui merge 1:1 sortvar using `reverse', keepusing(*_rev)
			qui replace FH_lo_MT_Program_pt_st = FH_lo_MT_Program_pt_st_rev if _merge==3
			qui replace FH_lo_CCT_Program_pt_st = FH_lo_CCT_Program_pt_st_rev if _merge==3
			
			replace p = 100 if p==102
			replace p = 100.5 if p==103
			sort p i
			drop _merge FH_lo_MT_Program_pt_st_rev FH_lo_CCT_Program_pt_st_rev sortvar i p
			
			gen blank = ""
# delimit ;			
texsave p_exp FH_up_MT_Program_pt_st FH_lo_MT_Program_pt_st blank FH_up_CCT_Program_pt_st FH_lo_CCT_Program_pt_st using "$output/AT11.tex", 
					replace align(rccccc) location(H) width(\textwidth) hlines(10)
					headerlines("& \multicolumn{2}{c}{Full-cost Program} & & \multicolumn{2}{c}{Reduced-cost Program} \\ 
					\cmidrule{2-3} \cmidrule{5-6} & Rank & Rank & & Rank & Rank \\ 
					& Preservation & Inversion & & Preservation   & Inversion \\
					& (1) & (2) & & (3) & (4) ") 
					marker(tb:fhbounds) title(\\ Fréchet-Höffding Bounds) 
					size(small) frag nonames nofix ;
# delimit cr							